<?php defined('SYSPATH') or die('No direct script access.') ?>
<table id="table-items" class="table table-hover">
	<tr>
		<th>#</th>
		<th>название</th>
		<th>ссылка</th>
		<th>кол-во</th>
		<th>доставка</th>
		<th>стоимость</th>
<?php
if ($role['name']=='admin' OR $role['name']=='performer')
{
?>
		<th>правка</th>
<?php
}
?>
		<th>статус</th>
<?php
if ($role['name']=='client')
{
?>
		<th>операции</th>
<?php
}
?>
	</tr>
<?php
foreach ($rows as &$row)
{
	$images = '';
	if (!empty($row['files']))
	{
		$imgs = explode(',',$row['files']);

		foreach($imgs as $img)
		{
			$images .= "<a class='box' href='/resize_1200x900/{$img}'><img src='/resize_h100/{$img}'><a>";
		}
	}
?>
	<tr>
		<td><?php echo $row['num'] ?></td>
		<td><a href="#" class="pop" data-toggle="popover" data-content="<?php echo htmlspecialchars($row['comment']).'<br>'.$images ?>" data-original-title="<?php echo $row['name'] ?>"><?php echo $row['name'] ?></a></td>
		<td><?php echo HTML::anchor($row['link'],'открыть',array('target'=>'_blank')) ?></td>
		<td><?php echo $row['quantity'] ?></td>
		<td><?php echo $row['delivery'] ?> ¥</td>
		<td><?php echo $row['cost'] ?> ¥</td>
<?php
if ($role['name']=='client' AND $order['complete']!='готов')
{
?>
		<td><?php echo $row['status'] ?></td>
		<td>
			<button type="button" class="btn btn-default btn-xs" id="item_<?php echo $row['id'] ?>_edit"><span class="glyphicon glyphicon-pencil"></span> Редактировать</button>
  			<button type="button" class="btn btn-default btn-xs" id="item_<?php echo $row['id'] ?>_delete"><span class="glyphicon glyphicon-trash"></span> Удалить</button>
  		</td>
<?php
}
elseif ($role['name']=='client' AND $order['complete']=='готов')
{
?>
		<td><?php echo $row['status'] ?></td>
		<td>Заблокирован</td>
<?php
}
elseif ($role['name']=='admin' OR $role['name']=='performer')
{
?>
		<td class="editbtn">
			<button type="button" class="btn btn-default " id="item_<?php echo $orderid.'_'.$row['id'] ?>_edit"><span class="glyphicon glyphicon-pencil"></span></button>
							<span class="btn btn-default fileinput-button">
								<i class="glyphicon glyphicon-camera"></i>
								<!--<span>Добавить</span>-->
								<!-- The file input field used as target for the file upload widget -->
								<input id="item_<?php echo $orderid.'_'.$row['id'] ?>_photoupload" class="photoupload" type="file" name="files" multiple data-url= "<?php echo URL::site('upload/' . $orderid.'/'.$row['id']) ?>" accept="image/jpeg,image/png,image/gif">
							</span>
   <!--<input class="btn btn-default photoupload" type="file" name="files" multiple="" data-url="/upload/43" accept="image/jpeg,image/png,image/gif">-->
			<!--<button type="button" class="btn btn-default photoupload" id="item_<?php echo $row['id'] ?>_photoupload"><span class="glyphicon glyphicon-camera"></span></button>-->
			<button type="button" class="btn btn-default " id="item_<?php echo $row['id'] ?>_photoreport">загружено <span class="badge">0</span></button>
		</td>
		<td>
			<?php echo Form::select('status_items_'.$row['id'], $enum, $row['status'],array('class'=>'form-control')) ?>
		</td>
<?php
}
?>
	</tr>
<?php
}
?>
</table>